﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ScopeProperty.cs" company="JDML Consulting Ltd.">
//   Copyright 2011 Photon Project - http://photon.codeplex.com
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Photon.Windows
{
    using System;
    using System.Windows;

    /// <summary>
    /// Represents a <see cref="DependencyProperty"/> that has scope.
    /// </summary>
    public class ScopeProperty
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ScopeProperty"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="defaultMetadata">The default metadata.</param>
        private ScopeProperty(DependencyProperty property, ScopePropertyMetadata defaultMetadata)
        {
            Property = property;
            DefaultMetadata = defaultMetadata;
        }

        /// <summary>
        /// Gets the property.
        /// </summary>
        /// <value>The property.</value>
        public DependencyProperty Property { get; private set; }

        /// <summary>
        /// Gets the default metadata.
        /// </summary>
        /// <value>The default metadata.</value>
        public ScopePropertyMetadata DefaultMetadata { get; private set; }

        /// <summary>
        /// Registers an attached scope dependency property.
        /// </summary>
        /// <param name="name">The name of the dependency property to register.</param>
        /// <param name="propertyType">The type of the property.</param>
        /// <param name="ownerType">The owner type that is registering the dependency property.</param>
        /// <param name="defaultMetaData">The default meta data.</param>
        /// <returns>The registered property.</returns>
        public static ScopeProperty RegisterAttached(string name, Type propertyType, Type ownerType, 
            ScopePropertyMetadata defaultMetaData)
        {
            var property = DependencyProperty.RegisterAttached(name, propertyType, ownerType, defaultMetaData);
            return new ScopeProperty(property, defaultMetaData);
        }

        /// <summary>
        /// Registers a scope dependency property.
        /// </summary>
        /// <param name="name">The name of the dependency property to register.</param>
        /// <param name="propertyType">The type of the property.</param>
        /// <param name="ownerType">The owner type that is registering the dependency property.</param>
        /// <param name="defaultMetaData">The default meta data.</param>
        /// <returns>The registered property.</returns>
        public static ScopeProperty Register(string name, Type propertyType, Type ownerType, 
            ScopePropertyMetadata defaultMetaData)
        {
            var property = DependencyProperty.Register(name, propertyType, ownerType, defaultMetaData);
            return new ScopeProperty(property, defaultMetaData);
        }
    }
}